<template>
  <n-space vertical>
    <n-select
      style="width: 200px"
      v-model:value="value"
      @update:value="handleUpdateValue"
      :options="options"
    />
    <n-input style="width: 200px" v-model:value="text" />
  </n-space>
</template>

<script setup lang="ts">
import { computed, ref, onMounted } from 'vue'
import { NSelect } from 'naive-ui'
import apis from '../handles/apis'
const value = ref(null)
const text = ref(null)
let props = defineProps({
  data: {
    type: Array,
    default: () => []
  }
})

const options = computed(() =>
  props.data.map((item: any) => {
    return {
      label: item.imeName,
      value: item.index
    }
  })
)

// 初始化
onMounted(async () => {
  let resp = await apis.getJSON(apis.users)
  console.log(resp)
})
// 更新值
const handleUpdateValue = () => {
  console.log(value.value)
  window.ipcRenderer.send('switchInputMethods', { index: value.value })
}
</script>
